<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Binh
 * Date: 12/18/13
 * Time: 1:23 AM
 * To change this template use File | Settings | File Templates.
 */

use \Model\Song;

class Controller_Home extends Controller{
    private $view;

    public function __construct(){
        //Cài đặt view
        $this->view = View::forge('home/layout');
        $this->view->head = View::forge('home/head');
        $this->view->header = View::forge('home/header');
        $this->view->footer = View::forge('home/footer');

        $this->view->set_global('site', 'layout_home');
    }

    public function action_index(){
        return $this->set_layout(Song::get_new_song(), Song::get_top_vn(), Song::get_top_ngoai());
    }

    //Cài đặt layout
    private function set_layout($songs_new, $top_song_vn, $top_song_foreign){
        $this->view->layout_home = View::forge('home/layout_home');

        $this->view->set_global('list_song', $songs_new);
        $this->view->set_global('top_vn', $top_song_vn);
        $this->view->set_global('top_ngoai', $top_song_foreign);

        return $this->view;
    }
}